//
//  Sample.m
//  CocoaSynth
//
//  Created by Jérémy Brault on 09/02/10.
//  Copyright 2010 None. All rights reserved.
//

#import "Sample.h"
#import "System.h"

@implementation Sample

#pragma mark -
#pragma mark Accessors

@synthesize voltages;

#pragma mark -
#pragma mark Memory Management

- (id)init 
{
	if (self = [super init]) {
		NSMutableArray* tmp = [[NSMutableArray alloc] init];
		
		NSUInteger sampleSize = [[System sharedSystem] sampleSize];
		
		for (int i = 0; i < sampleSize; i++) {
			[tmp addObject:[NSNumber numberWithFloat:0]];
		}
		
		voltages = [tmp retain];
		[tmp release];
	}
	
	return self;
}

- (id)initWithVoltages:(NSArray*)theVoltages
{
	if (self = [super init]) {
		voltages = [theVoltages retain];
	}
	return self;	
}

- (void)dealloc 
{
	[voltages release];
	voltages = nil;
	
	[super dealloc];
}
#pragma mark -
#pragma mark NSCopying Implementation
- (id)copyWithZone:(NSZone *)zone
{
	Sample* copy = [[Sample allocWithZone:zone] init];
	NSArray* vs = [[self voltages] copy];
 	[copy setVoltages:vs];
	[vs release];
	
	return copy;
}

#pragma mark -
#pragma mark Description

- (NSString*)description {
	return [voltages description]; 
}

@end
